page edit
ページ全体を書き換えます。デフォルトで楽観ロックが有効です。 書式
cos page edit <title> --from-file <path> [--input-format <fmt>] [--expect-commit <id> | --force] --project <name>
フラグ
--from-file <path> — 入力ファイル (- で stdin)、必須
--input-format <fmt> — 入力形式: txt(デフォルト) / md (Markdown を自動変換)
--expect-commit <id> — 期待 commitId。不一致なら exit 6 で停止 (推奨)
--force — 楽観ロックを無効化して強制上書き
--dry-run — 実行せずプレビューを表示
使用例
code:bash
# 1. commitId を取得
COMMIT=$(cos page get "タイトル" --project myproject --json --results-only --select 'commitId')
# 2. dry-run で確認
cos page edit "タイトル" --from-file ./content.txt --expect-commit "$COMMIT" --project myproject --dry-run
# 3. 本実行
cos page edit "タイトル" --from-file ./content.txt --expect-commit "$COMMIT" --project myproject
# Markdown ファイルから (自動変換)
cos page edit "タイトル" --from-file ./content.md --input-format=md --expect-commit "$COMMIT" --project myproject
# stdin から
echo "新しい本文" | cos page edit "タイトル" --from-file - --expect-commit "$COMMIT" --project myproject
関連ページ